<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/27 0027
 * Time: 9:19
 */
include "config.php";
if (isset($_REQUEST["gid"])){
    $GID=$_REQUEST["gid"];

    $goodsStr=file_get_contents("./data/goodsList.json");
    //把字符串转对象
    $goodsList=json_decode($goodsStr);

    for($i=0;$i<count($goodsList);$i++){
        if ($goodsList[$i]->gId==$GID){
            print_r(json_encode($goodsList[$i]));
            break;
        }
    }
}else{
    $goodsStr=file_get_contents("./data/goodsList.json");
    print_r($goodsStr);
}